export default {
	data() {
		return {
			order_id: '',
			orderDetail: {},
			btns: {
				btn1: false,
				btn2: false,
				btn3: false,
				btn4: false,
				btn5: false,
				btn6: false,
				btn7: false,
				btn8: false,
				btn9: false,
			},
			times: {
				time1: true,
				time2: true,
				time3: true,
				time4: true,
			}
		};
	},
	onLoad(options) {
		this.order_id = options.order_id;
		this.getLoadData();
	},
	methods: {
		getStatusName() {
			var statusname = this.orderDetail.status_text;
			if (this.check.isNull(statusname)) {
				switch (this.orderDetail.status) {
					case 0: {
						statusname = "待审核";
						break;
					}
					case 1: {
						statusname = "待分配";
						break;
					}
					case 2: {
						statusname = "待接货";
						break;
					}
					case 3: {
						statusname = "待支付";
						break;
					}
					case 4: {
						statusname = "待装车";
						break;
					}
					case 5: {
						statusname = "待送达";
						break;
					}
					case 6: {
						statusname = "待评价";
						break;
					}
					case 7: {
						statusname = "已评价订单完成";
						break;
					}
					case 99: {
						statusname = "订单已取消";
						break;
					}
					case 98: {
						statusname = "审核拒绝";
						break;
					}
					default: {
						statusname = "";
						break;
					}
				}
				return statusname;
			} else {
				return statusname;
			}
		},
		getPayMode() {
			//  1:现付  2:货到付款 3:提付',
			var paymode = '';
			switch (this.orderDetail.pay_mode) {
				case 1: {
					paymode = "现付";
					break;
				}
				case 2: {
					paymode = "货到付款";
					break;
				}
				default: {
					paymode = "提付";
					break;
				}
			}
			return paymode;
		},
		getPolicyNo() {
			var policy_no = this.orderDetail.policyNo;
			if (this.check.isNull(policy_no)) {
				policy_no = "无";
			}
			return policy_no;
		},
		getPolicyFee() {
			var policy_fee = this.orderDetail.policy_fee;
			if (policy_fee == 0) {
				policy_fee = "0.00";
			}
			return policy_fee;
		},
		getFreight() {
			var freight = this.orderDetail.freight;
			if (freight == 0) {
				freight = "0.00";
			}
			return freight;
		},
		getOtherMoney() {
			var other_fee = this.orderDetail.other_fee;
			if (other_fee == 0) {
				other_fee = "0.00";
			}
			return other_fee;
		},
		getTotalMoney() {
			var total = this.orderDetail.total;
			if (total == 0) {
				total = "0.00";
			}
			return total;
		},
		getStartTitle() {
			var title = '';
			switch (this.orderDetail.status) {
				case 5: {
					title = "接货时间:";
					break;
				}
				case 6: {
					title = "接货时间:";
					break;
				}
				case 7: {
					title = "接货时间:";
					break;
				}
				case 99: {
					title = "取消时间:";
					break;
				}
				case 98: {
					title = "拒绝时间:";
					break;
				}
				default: {

					break;
				}
			}
			return title;
		},
		getStartDate() {
			var start = '';
			switch (this.orderDetail.status) {
				case 5: {
					start = this.orderDetail.load_time;
					break;
				}
				case 6: {
					start = this.orderDetail.load_time;
					break;
				}
				case 7: {
					start = this.orderDetail.load_time;
					break;
				}
				case 99: {
					if (this.check.isNull(this.orderDetail.update_time)) {
						start = this.orderDetail.arrive_time;
					} else {
						start = this.orderDetail.update_time;
					}
					break;
				}
				case 98: {
					if (this.check.isNull(this.orderDetail.update_time)) {
						start = this.orderDetail.arrive_time;
					} else {
						start = this.orderDetail.update_time;
					}
					break;
				}
				default: {
					break;
				}
			}
			return start;
		},
		getEndTitle() {
			var title = '';
			switch (this.orderDetail.status) {
				case 6: {
					title = "送达时间:";
					break;
				}
				case 7: {
					title = "送达时间:";
					break;
				}
				case 98: {
					title = "拒绝时间:";
					break;
				}
				default: {
					break;
				}
			}
			return title;
		},
		getEndDate() {
			var end = '';
			switch (this.orderDetail.status) {
				case 6: {
					if (this.check.isNull(this.orderDetail.songda_time)) {
						end = this.orderDetail.arrive_time;
					} else {
						end = this.orderDetail.songda_time;
					}

					break;
				}
				case 7: {
					if (this.check.isNull(this.orderDetail.songda_time)) {
						end = this.orderDetail.arrive_time;
					} else {
						end = this.orderDetail.songda_time;
					}
					break;
				}
				case 98: {
					end = this.orderDetail.approval_remark;
					break;
				}
				default: {

					break;
				}
			}
			return end;
		},
		getPayStatus() {
			//    是否支付（0：未支付；1：已支付；2：部分支付）
			var ispay = '';
			switch (this.orderDetail.is_pay) {
				case 1: {
					ispay = "已支付";
					break;
				}
				case 2: {
					ispay = "部分支付";
					break;
				}
				default: {
					ispay = "未支付";
					break;
				}
			}
			return ispay;
		},
		getOrderTimes() {
			switch (this.orderDetail.status) {
				case 0: case 1:case 2:case 3:case 4: {
					this.times.time1 = true;
					this.times.time2 = true;
					this.times.time3 = false;
					this.times.time4 = false;
					break;
				}  
				  
				case 5:case 99: {
					this.times.time1 = true;
					this.times.time2 = true;
					this.times.time3 = true;
					this.times.time4 = false;
					break;
				}
				case 6: case 7: case 98: {
					this.times.time1 = true;
					this.times.time2 = true;
					this.times.time3 = true;
					this.times.time4 = true;
					break;
				} 
				default: {
					this.times.time1 = true;
					this.times.time2 = false;
					this.times.time3 = false;
					this.times.time4 = false;
					break;
				}
			}
		},
		getOrderBtns(){
			this.btns.btn1 = false;
			this.btns.btn2 = false;
			this.btns.btn3 = false;
			this.btns.btn4 = false;
			this.btns.btn5 = false;
			this.btns.btn6 = false;
			this.btns.btn7 = false;
			this.btns.btn8 = false;
			this.btns.btn9 = false;
			 //    订单状态（0待审核  1待分配  2待接货  3待支付  4待装车  5待送达  6已送达待评价  7已评价订单完成  99订单已取消  98审核拒绝）
			    // ['all', 2, 3, 5, 6, 7, -1, -2]
				// 1运单合同,2签订合同,3货物轨迹,4去评价,5去支付,6取消订单,7确认送达,8二维码,9删除订单
			    switch (this.orderDetail.status) {
			        case  0:{
						this.btns.btn6 = true;
			            break;
			        }
			        case  1:{
						this.btns.btn6 = true;
			            break;
			        }
			        case  2:{
						this.btns.btn6 = true;
						this.btns.btn8 = true;
			            break;
			        }
			        case  3:{
						this.btns.btn1 = true;
						this.btns.btn5 = true;
						this.btns.btn6 = true;
			            break;
			        }
			        case  4:{
						this.btns.btn1 = true;
						this.btns.btn8 = true;
			            break;
			        }
			        case  5:{
			            //   1:现付  2:货到付款 3:提付',
			            switch (this.orderDetail.pay_mode) {
			                case 1:{
			                    if (this.orderDetail.is_pay != 1) {
									this.btns.btn5 = true;
			                    }
			                    break;
			                }
			                default:{
			                    break;
			                }
			            }
						this.btns.btn6 = true;
						this.btns.btn3 = true;
			            break;
			        }
			        case  6:{
			            // 1:现付  2:货到付款 3:提付',
			            switch (this.orderDetail.pay_mode) {
			                case 1: case 2:{
			                    if (this.orderDetail.is_pay != 1) {
			                        this.btns.btn5 = true;
			                    }
			                    break;
			                }
			                default:{
			                    
			                    break;
			                }
			            }
						this.btns.btn3 = true;
						this.btns.btn4 = true;
			            break;
			        }
			        case  7:{
						this.btns.btn3 = true;
			            break;
			        }
			        case  99:{
						this.btns.btn9 = true;
			            break;
			        }
			        case  98:{
						this.btns.btn9 = true;
			            break;
			        }
			        default:{
			            break;
			        }
			    }
		},
		getLoadData() {
			var data = {
				order_id: this.order_id,
			}
			this.$refs.loadingCover.show();
			this.http.sendRequest({
				api: this.api.order.waybillDetailApi,
				data: data,
				success: res => {
					console.log(res)
					var message = res.message;
					if (res.success == 'true' && res.data) {
						if (this.check.isNull(message)) {
							message = '获取详情成功'
						}
						this.orderDetail = res.data;
						this.getOrderTimes();
						this.getOrderBtns();
					} else {
						if (this.check.isNull(message)) {
							message = '获取详情失败'
						}
					}
					uni.showToast({
						title: message
					})
					if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
				},
				fail: res => {
					if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
				}
			});
		},
	}
};
